import request from "@/utils/request"

// 获取spu列表数据的接口  get /admin/product/{page}/{limit}  category3Id
export const reqGetSpuList = (page, limit, category3Id) => {
  return request({
    url: `/admin/product/${page}/${limit}`,
    method: "get",
    params: {
      category3Id,
    },
  })
}

//  获取某一个SPU信息  /admin/product/getSpuById/{spuId}  get
export const reqGetSpu = (spuId) => {
  return request({
    url: `/admin/product/getSpuById/${spuId}`,
    method: "get",
  })
}

// 获取品牌的信息  /admin/product/baseTrademark/getTrademarkList get
export const reqGetTradeMarkList = () => {
  return request({
    url: `/admin/product/baseTrademark/getTrademarkList`,
    method: "get",
  })
}

// 获取spu图片 /admin/product/spuImageList/{spuId} get
export const reqGetSpuImageList = (spuId) => {
  return request({
    url: `/admin/product/spuImageList/${spuId}`,
    method: "get",
  })
}

// 获取平台中全部的销售属性 整个平台只有三个销售属性
export const reqGetBaseSaleAttrList = () => {
  return request({
    url: `/admin/product/baseSaleAttrList`,
    method: "get",
  })
}

// 保存修改SPU | 添加SPU的接口 它们两个携带给服务器的参数大致一样的，唯一的区别是参数是否携带id
// /admin/product/updateSpuInfo post  /admin/product/saveSpuInfo post
export const reqAddOrUpdateSpu = (spuInfo) => {
  // 携带参数带有id 修改spu
  if (spuInfo.id) {
    return request({
      url: `/admin/product/updateSpuInfo`,
      method: "post",
      data: spuInfo,
    })
  } else {
    return request({
      url: `/admin/product/saveSpuInfo`,
      method: "post",
      data: spuInfo,
    })
  }
}

// 删除SPU /admin/product/deleteSpu/{spuId} delete
export const reqDeleteSpu = (spuId) => {
  return request({
    url: `/admin/product/deleteSpu/${spuId}`,
    method: "delete",
  })
}

// 添加sku /admin/product/saveSkuInfo post
export const reqSaveSkuInfo = (skuInfo) => {
  return request({
    url: "/admin/product/saveSkuInfo",
    method: "post",
    data: skuInfo,
  })
}

// 查看当前spu的sku列表 /admin/product/findBySpuId/{spuId} get
export const reqFindSkuBySquId = (spuId) => {
  return request({
    url: `/admin/product/findBySpuId/${spuId}`,
    method: "get",
  })
}
